package SimplePractice;
import util.ListNode;

public class Demo141 {
	public static void main(String[] args){
		System.out.println(hasCycle(null));
	}
	
    private static boolean hasCycle(ListNode head) {
    	
    	ListNode fast = head;
    	ListNode slow = head;
    	
    	while(fast != null && fast.next != null) {
    		fast = fast.next.next;
    		slow = slow.next;
    		
    		if(fast == slow)
    			return true;
    	}
    	
    	return false;
        
    }
}
